<%@ include file="/inc/top.jsp" %>
<%@ page import="com.novix.portal.framework.util.IConstants" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="lotus.domino.Document" %>
<%@ page import="com.novix.portal.framework.model.impl.WebOrganization" %>
<%@ page import="java.util.ArrayList" %>
<html:form action="/domino/viewOrganizations" method="post">
<%
  List list = (List)session.getAttribute(IConstants.WEB_ORGANIZATIONS);

  if (request.getParameter("id") != null) {
    String id        = request.getParameter("id");
    List   alphaList = new ArrayList();

    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
      WebOrganization element = (WebOrganization)iter.next();

      if (element.getCompanyName() != null && element.getCompanyName().toUpperCase().startsWith(id)) {
        alphaList.add(element);
      }
    }

    request.setAttribute("list", alphaList);
  } else {
    request.setAttribute("list", list);
  }

  String href = request.getScheme() + "://" + request.getServerName() + "/" + getServletContext().getInitParameter(
          IConstants.DOMINO_LEGACY_PATH) + "/contactdoc";
          
%>
  <DIV align="center">
    <a href="<%= basePath %>/do/domino/viewOrganizations">All</A>
    <br>
<%
    for (char letter = 'A'; letter <= 'Z'; letter++) {
      out.print("<a href=" + basePath + "/do/domino/viewOrganizations?id=" + letter + ">" + letter + "</A>&nbsp;&nbsp;&nbsp;"
              );
    }
%>
  </DIV>
  <display:table name="list" export="false" id="wo" class="<%= uc.getUser().getCaptive().toLowerCase() %>" style="width:100%">
  <%  WebOrganization webOrg =  (WebOrganization)pageContext.getAttribute("wo"); %>
    <display:caption>
      <%= "Organization Links for " + uc.getUser().getCaptive() + " Captives " %>
    </display:caption>
    <display:setProperty name="export.xml" value="false" />
    <display:setProperty name="export.csv" value="false" />
    <display:setProperty name="export.pdf" value="false" />
    <display:setProperty name="basic.msg.empty_list" value="No organizations found." />
    <display:column property="companyName" title="Company Name" sortable="true" />
    <display:column property="officeCity" title="City" sortable="true" />
    <display:column property="officeState" title="ST" sortable="true" />
    <display:column property="officePhoneNumber" title="Phone" sortable="true" />

   <display:column title="NAICS" sortable="true">
    <% 
   
	List naicslist	=  webOrg.getNAICS(); 
    	if(naicslist!=null && naicslist.size()>0){
			int i =1;
		    for (Iterator iter = naicslist.iterator(); iter.hasNext();) {
	            String element = (String) iter.next();
	            if(i<naicslist.size())
	                out.print(element + ", ");
	            else
	                out.print(element );
	            i++;    
	            
	        }
       }
    %>
    </display:column>

    <display:column title="Region" sortable="true" width="10px" style="width: 13px" maxLength="15" property="ienregion"/>
    <display:column title="Description" sortable="true" >
   <%
      out.println(webOrg.getOrgComment());
      if (webOrg.getLink() != null) {
        out.print("<br> <a style='font-size: xx-small;'; href='http://" + webOrg.getLink() + "' target=_blank>" + 
        webOrg.getLink() + "</a> ");
      }
      
 %> 
    </display:column>
    <display:column title="Contacts" sortable="false">
      <%= "<a href='" + basePath + "do/domino/viewContacts?boardInvitee=true&showall=true&category=BI&companyId=" + ((
              WebOrganization)pageContext.getAttribute("wo")).getCompanyId() + "'>" + "Contacts" %></a>
  </display:column>
</display:table>
<input type="hidden" value="" id="companyId" name="companyId">
</html:form>
<%@ include file="/inc/footer.jsp" %>
